﻿using Clinic.Extensions;
using Clinic.ViewModels.Main;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Messaging;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Clinic.Views.Main
{
    /// <summary>
    /// NonClientAreaContent.xaml 的交互逻辑
    /// </summary>
    public partial class NonClientAreaContent
    {
        public NonClientAreaContent()
        {
            InitializeComponent();

            Skin skin = new Skin();
            string key = App.Configuration.AppSettings.Settings["SkinType"].Value;
            if (!string.IsNullOrWhiteSpace(key))
            {
                SkinType skinType = (SkinType)Enum.Parse(typeof(SkinType), key);
                if (skinType != SkinType.Default)
                    skin.UpdateSkin(skinType);
            }
            else
            {
                skin.UpdateSkin(SkinType.Default);
            }
        }
        private void ButtonConfig_OnClick(object sender, RoutedEventArgs e) => PopupConfig.IsOpen = true;
        private async void ButtonSkins_OnClick(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button { Tag: SkinType skinType })
            {
                PopupConfig.IsOpen = false;
                Skin skin = new Skin();
                await skin.UpdateSkin(skinType);
            }
        }
    }
}
